{% extends  'weui/base.html' %}

{% block custom_css_js %}
{% if not item_id %}
<script type="text/javascript">
function GetQueryString(name)
{
  var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
  var r = window.location.search.substr(1).match(reg);
  if(r!=null)return  unescape(r[2]); return null;
}

var ua = navigator.userAgent.toLowerCase();
next_page = "{{ next_page }}"
if(null==next_page || ""==next_page) {
  next_page = GetQueryString("next");
  if(null==next_page || ""==next_page) {
    next_page = '/account/'
  }
}
referrer = "{{ referrer }}"
if(null==referrer || ""==referrer) {
  referrer = GetQueryString("referrer");
  if(null==referrer || ""==referrer) {
    referrer = 'unknown'
  }
}
encode_next_page = encodeURIComponent(next_page);
// alert(ua+'\n'+encode_next_page);
if(/micromessenger/.test(ua) && next_page != '/account/') {
  document.title="正在微信验证...请稍等";
  window.location.href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxf78da8e222832632&redirect_uri=https%3A%2F%2Fwww.ztm.me%2Faccount%2Fsignin%2F%3Fnext%3D'+encode_next_page+'&response_type=code&scope=snsapi_base&state=123#wechat_redirect'
}
</script>
{% endif %}

<script>
f23={}
f23.ts="8ABC7DLO5MN6Z9EFGdeJfghijkHIVrstuvwWSTUXYabclmnopqKPQRxyz01234"
f23.s52e=function(n)
{
  var nl=n.length,t=[],a,b,c,x,m=function(y){t[t.length]=f23.ts.charAt(y)},N=f23.ts.length,N2=N*N,N5=N*5
  for(x=0;x<nl;x++)
  {
    a=n.charCodeAt(x)
    if(a<N5)m(Math.floor(a/N)),m(a%N)
    else m(Math.floor(a/N2)+5),m(Math.floor(a/N)%N),m(a%N)
  }
  var s=t.join("")
  return String(s.length).length+String(s.length)+s
}
</script>
{% endblock %}

{% block title%}
{% if item_id %}长按二维码查看{% else %}请登录{% endif %}
{% endblock %}

{% block base_content%}
<!--主体-->
<h3 class="blue_title"></h3>
{% if item_id %}
<div id="dialogs">
  <div class="js_dialog" id="iosDialog2">
      <div class="weui-mask"></div>
      <div class="weui-dialog">
          <div class="weui-dialog__bd">
            <p id="img_p"><img src="/static/img/loading3.gif" alt="loading" /></p>
            <p id="desc_p">请稍等...正在生成二维码</p>
          </div><!--
          <div class="weui-dialog__ft">
              <a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_primary">关闭</a>
          </div>-->
      </div>
  </div>
</div>
<script type="text/javascript">
  $(function(){
      // $iosDialog2.fadeIn(200);
      setTimeout(function() {
      document.getElementById("img_p").innerHTML = '<img src="https://www.ztm.me/weixin/share/post/?item_id={{ item_id }}&referrer={{ referrer }}" alt="post" style="width:242px;height:382px;" />';
        document.getElementById("desc_p").innerText = '长按二维码查看';
      }, 1000);
  });
  $('#dialogs').on('click', '.weui-dialog__btn', function(){
      $(this).parents('.js_dialog').fadeOut(200);
  });
</script>
{% else %}
<form role="form" method="POST" id="signinForm" action="/account/signin/">
{% csrf_token %}
<input type="hidden" name="next" id="id_next" value="{{next}}" />
<div class="weui-cells__title">请登录</div>
<div class="weui-cells weui-cells_form">
  <div class="weui-cell">
    <div class="weui-cell__hd"><label class="weui-label">账号</label></div>
    <div class="weui-cell__bd">
      <input class="weui-input" name="username" type="text" placeholder="请输入登录账号">
    </div>
  </div>
  <div class="weui-cell">
    <div class="weui-cell__hd"><label class="weui-label">密码</label></div>
    <div class="weui-cell__bd">
      <input class="weui-input" id="exampleInputPassword1" name="password" type="password" placeholder="请输入登录密码">
    </div>
  </div>
</div>
<input type="submit" class="weui-btn weui-btn_default" onclick="exampleInputPassword1.value=f23.s52e(exampleInputPassword1.value)" value="登 录" />
</form>
{% endif %}
<!--主体 end-->
      <div class="container">
        <hr>
        <footer>
          <p>&copy; www.ztm.me 2017 <a href="http://www.beian.miit.gov.cn" target="_blank">苏ICP备17042377号</a> 当前路径:{{ request.path }}</p>
          <p>联系我们: <a mailto="service@ztm.me">service(at)ztm.me</a></p>
        </footer>
      </div>
{% endblock %}
